package org.sunshine.miracle.model;

public class VirtualFile implements Cloneable{

    private Long id;
    private String name;
    private boolean isVirtual = true;
    private boolean isFolder = true;
    private String absolutePath;
    private Long parentId;
    private Long childrenCount = (long) 0;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public boolean isVirtual() {
        return isVirtual;
    }

    public void setVirtual(boolean virtual) {
        isVirtual = virtual;
    }

    public boolean isFolder() {
        return isFolder;
    }

    public void setFolder(boolean folder) {
        isFolder = folder;
    }

    public String getAbsolutePath() {
        return absolutePath;
    }

    public void setAbsolutePath(String absolutePath) {
        this.absolutePath = absolutePath;
    }

    public Long getParentId() {
        return parentId;
    }

    public void setParentId(Long parentId) {
        this.parentId = parentId;
    }

    public Long getChildrenCount() {
        return childrenCount;
    }

    public void setChildrenCount(Long childrenCount) {
        this.childrenCount = childrenCount;
    }

    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        VirtualFile file = (VirtualFile) o;

        if (isFolder != file.isFolder) return false;
        if (isVirtual != file.isVirtual) return false;
        if (absolutePath != null ? !absolutePath.equals(file.absolutePath) : file.absolutePath != null) return false;
        if (childrenCount != null ? !childrenCount.equals(file.childrenCount) : file.childrenCount != null) return false;
        if (id != null ? !id.equals(file.id) : file.id != null) return false;
        if (name != null ? !name.equals(file.name) : file.name != null) return false;
        if (parentId != null ? !parentId.equals(file.parentId) : file.parentId != null) return false;

        return true;
    }

    public int hashCode() {
        int result;
        result = (id != null ? id.hashCode() : 0);
        result = 31 * result + (name != null ? name.hashCode() : 0);
        result = 31 * result + (isVirtual ? 1 : 0);
        result = 31 * result + (isFolder ? 1 : 0);
        result = 31 * result + (absolutePath != null ? absolutePath.hashCode() : 0);
        result = 31 * result + (parentId != null ? parentId.hashCode() : 0);
        result = 31 * result + (childrenCount != null ? childrenCount.hashCode() : 0);
        return result;
    }


    public String toString() {
        return "VirtualFile{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", isVirtual=" + isVirtual +
                ", isFolder=" + isFolder +
                ", absolutePath='" + absolutePath + '\'' +
                ", parentId=" + parentId +
                ", childrenCount=" + childrenCount +
                '}';
    }

    public VirtualFile clone() {
        VirtualFile file = null;
        try {
            file = (VirtualFile) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException(e);
        }
        return file;
    }
}
